package com.fpx.order.plat.bussiness.plat.ebay.task;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.fpx.order.plat.bussiness.dao.log.IPullOrderLogDao;
import com.fpx.order.plat.bussiness.entity.CustomerShop;
import com.fpx.order.plat.bussiness.plat.base.PlatOrderCurrentJob;
import com.fpx.order.plat.bussiness.plat.ebay.service.EbayDeliveryOrderHandler;
import com.fpx.order.plat.bussiness.system.PlatConstants;

@Component
public class EbayDeliveryOrderJob extends PlatOrderCurrentJob{

	private final static Logger LOGGER = Logger.getLogger(EbayDeliveryOrderJob.class);
	
	@Autowired
	private EbayDeliveryOrderHandler ebayDeliveryOrderHandler;
	
	@Autowired
	private IPullOrderLogDao pullOrderLogDao;
	/**
	 * 定时任务
	 */
	public void exec(){
		LOGGER.info("【EBAY】 自动同步平台订单开始.....");
		initMeodth(PlatConstants.ORDER_SOURCE_EBAY);
	    List<CustomerShop> customerLst=super.getCustomers();
		if(!org.springframework.util.StringUtils.isEmpty(customerLst)){
		// 遍历商家和店铺
		 for (CustomerShop customer : customerLst) {
			 String cm_id=customer.getCm_id();
			 String cs_id=customer.getCs_id();
		     try {
//		    	 if("551837".equals(cm_id)&&"2324".equals(cs_id)){
		    		 ebayDeliveryOrderHandler.deliveryOrder(customer,0);
//		    	 }
		     }catch (Exception ex) {
		    	 LOGGER.error("【EBAY】---商家:["+cm_id+"]-商铺ID:["+cs_id+"]-【异常信息】: "+ex.getMessage());
		     }
		   } 
		}
       LOGGER.info("【EBAY】  自动同步平台订单结束");
	}
}
